package com.xyongfeng.foodManagement.mapper;

import com.xyongfeng.foodManagement.domain.Permission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author xyongfeng
* @description 针对表【permission】的数据库操作Mapper
* @createDate 2024-06-10 13:53:47
* @Entity generator.domain.Permission
*/
public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("SELECT distinct p.* FROM t_role r,t_admin_role ar,t_permission p,t_role_permission rp WHERE ar.admin_id = #{adminId} AND ar.role_id = r.role_id AND rp.role_id = r.role_id AND rp.permission_id = p.permission_id;")
    List<Permission> getByAdminId(@Param("adminId") Integer adminId);

    @Select("SELECT p.* FROM t_permission p,t_role_permission rp WHERE rp.role_id = #{roleId} AND rp.permission_id = p.permission_id;")
    List<Permission> getByRoleId(@Param("roleId") Integer roleId);
}




